#include<stdio.h>

void ShellSort(int* a, int n)
{
	int gap = n;
	while (gap > 1)
	{
		gap = gap / 3 + 1;
		for (int i = 0; i < n - gap; i++)
		{
			int begin = i;
			int temp = a[begin + gap];
			while (begin >= 0)
			{
				if (a[begin] > temp)
				{
					a[begin + gap] = a[begin];
					begin -= gap;
				}
				else
				{
					break;
				}
			}
			a[begin + gap] = temp;
		}
	}
}

int main()
{
	int arr[] = { 1,4,3,2,6,7,9,10,3 };
	for (int i = 0; i < sizeof(arr) / sizeof(arr[0]); i++)
	{
		printf("%d ", arr[i]);
	}
	printf("\n");
	ShellSort(arr, sizeof(arr) / sizeof(arr[0]));
	for (int i=0;i< sizeof(arr) / sizeof(arr[0]);i++)
	{
		printf("%d ", arr[i]);
	}
	printf("\n");
	return 0;
}